<?php
require("global.php");
if($phprpg->input['submit']){
	if($phprpg->input['withdraw'] > 0){
		if($phprpg->input['withdraw'] > $phprpg->player['bank']){
			$error[] = "You cannot withdraw more money than you have";
		}else{
			$update['money'] = $phprpg->player['money'] + $phprpg->input['withdraw'];
			$update['bank'] = $phprpg->player['bank'] - $phprpg->input['withdraw'];
			$db->update("players",$update,"pid=".$phprpg->player['pid']);
		}
	}elseif($phprpg->input['deposit'] > 0){
		if($phprpg->input['deposit'] > $phprpg->player['money']){
			$error[] = "You cannot deposit more money than you have";
		}else{
			$update['money'] = $phprpg->player['money'] - $phprpg->input['deposit'];
			$update['bank'] = $phprpg->player['bank'] + $phprpg->input['deposit'];
			$db->update("players",$update,"pid=".$phprpg->player['pid']);
		}
	}
	if(!isset($error)){
		header("location: bank.php");
	}
}
if(isset($error)){
	$errors = $phprpg->inline_error($error);
}
eval("\$bank = \"".$templates->get("bank")."\";");
$templates->output($bank);
?>